﻿/* 
 * Copyright (c) 2010 Letwory Interactive
 * All rights reserved.
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * -- Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * -- Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * Original contributor: Nathan Letwory
 */

using System;

namespace VerseSharp
{
    public class MaterialFragmentBlender: IMaterialFragment
    {
        public FragmentType ID { get { return FragmentType.Blender; } }
        public MaterialBlendType Type;
        public ushort DataA;
        public ushort DataB;
        public ushort DataControl;

        public void Deserialize(byte[] source, ref int pos)
        {
            Type = (MaterialBlendType)source[pos++];
            DataA = Utils.GetUInt16(source, ref pos);
            DataB= Utils.GetUInt16(source, ref pos);
            DataControl = Utils.GetUInt16(source, ref pos);
        }

        public void Serialize(byte[] destination, ref int pos)
        {
            destination[pos++] = (byte)Type;
            Utils.PutUInt16(destination, ref pos, DataA);
            Utils.PutUInt16(destination, ref pos, DataB);
            Utils.PutUInt16(destination, ref pos, DataControl);
        }
    }
}
